from grpc_helloWorld.probuff import helloworld_pb2, helloworld_pb2_grpc

import grpc

from concurrent import futures

class Greeter(helloworld_pb2_grpc.GreeterServicer):
    def SayHello(self, request, context):
        return helloworld_pb2.HelloReply(message='Hello, %s!' % request.name)


if __name__ == '__main__':
    # 实例化service
    service = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
    # 注册service
    helloworld_pb2_grpc.add_GreeterServicer_to_server(Greeter(), service)
    # 启动
    service.add_insecure_port('[::]:50053')
    service.start()
    service.wait_for_termination()